Method and apparatus for micro-code execution

ABSTRACT

A method for micro-code execution for an electronic device is disclosed. The method includes: providing the electronic device with a micro-code partitioned into a main core and at least a function code, the micro-code being stored in a first storage module of the electronic device; and when the electronic device is powered on, loading the main core from the first storage module into a second storage module of the electronic device, and switching between the second storage module for executing the main core and the first storage module for executing the function code to control operation of the electronic device. The function code is executed when called by execution of the main core.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to micro-code execution, and more specifically, to micro-code execution within optical disc drive systems.

2. Description of the Prior Art

It is very common for most computer users to upgrade, uninstall, and install software components. Methods exist to help facilitate the upgrade of hardware components of the personal computer and its associated peripheral devices by utilizing the so-called micro-code which is also known as firmware.

Please refer to FIG. 1. As shown in FIG. 1, the computer 110 is connected to the CD-ROM drive 160, and the CD-ROM drive 160 includes a disc 100, a controller 150, a decoder (DEC) 120, a microprocessor 130, a non-volatile memory 140, and a buffer memory 125. The non-volatile memory 140 is connected to the microprocessor 130 and is used for storage of all of the micro-code utilized by the CD-ROM drive 160. The buffer memory 125 is connected to the DEC 120 and is used for temporarily storing data such as a micro-code upgrade data.

Please refer to FIG. 2 as well as FIG. 1. FIG. 2 is a diagram illustrating the micro-code stored in the non-volatile memory 140. During operating mode, the microprocessor 130 accesses the micro-code section 210 of the non-volatile memory 140. When detecting that it is necessary for micro-code upgrading, the microprocessor 130 runs the upgrade program section 200 of the micro-code stored in the non-volatile memory 140, and begins executing the upgrade program. The upgrade program is responsible for moving the new version of the micro-code that is currently stored in the buffer memory 125 to a storage space located within the micro-code section 210 of FIG. 2. Finally, the microprocessor 130 resets in order to execute the new version of the micro-code.

It is important to note that the execution speed of microprocessor 130 is greater than the speed at which the microprocessor 130 is able to fetch code from the non-volatile memory 140. Therefore, because all of the micro-code is executed in non-volatile memory 140, and due to the processing versus fetching speed differences, the entire system performance of the CD-ROM drive 160 is reduced. Moreover, when updating the micro-code, the microprocessor 130 cannot have simultaneous read and write access to the non-volatile memory 140. Therefore, it is obvious that improvements in the micro-code execution apparatus 160 to solve the above mentioned disadvantages would be advantageous.

SUMMARY OF THE INVENTION

Therefore, one of the objectives of the claimed invention is to provide a method and apparatus for micro-code execution for an electronic device by switching between a main core stored in a first storage module and a function code stored in a second storage module, to solve the above problems.

According to an embodiment of the claimed invention, a method for micro-code execution for an electronic device is disclosed. The method comprises: providing the electronic device with a micro-code partitioned into a main core and at least a function code, the micro-code being stored in a first storage module of the electronic device; and when the electronic device is powered on, loading the main core from the first storage module into a second storage module of the electronic device, and switching between the second storage module for executing the main core and the first storage module for executing the function code to control operation of the electronic device; wherein the function code is executed when called by execution of the main core.

According to an embodiment of the claimed invention, a micro-code execution device is disclosed. The electronic device comprises: a first storage module storing a micro-code partitioned into a main core and at least a function code; a second storage module; and a microprocessor, electrically connected to the first storage module and the second storage module, for loading the main core from the first storage module into the second storage module and for switching between the second storage module for executing the main core and the first storage module for executing the function code to control operation of the electronic device when the electronic device is powered on, wherein the function code is executed when called by execution of the main core.

These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of a micro-code execution apparatus according to the prior art.

FIG. 2 is a diagram illustrating micro-code stored in the memory shown in FIG. 1.

FIG. 3 is a block diagram of an optical disc drive according to an embodiment of the present invention.

FIG. 4 is a flowchart showing the micro-code execution of the optical disc drive shown in FIG. 3.

DETAILED DESCRIPTION

To increase the system performance of the micro-code execution apparatus, such as an optical disc drive, and to prevent the problems described above that occur when updating micro-code when utilizing prior art techniques, it is advantageous to utilize the method and apparatus disclosed here to execute the micro-code. By way of example, and not limitation, the present invention is illustrated utilizing an exemplarily embodiment comprising an optical disc drive, the optical disc drive's micro-code, and the relevant components of an overall computing environment.

Please refer to FIG. 3. FIG. 3 is a block diagram of an optical disc drive 300 according to an embodiment of the present invention. As shown in FIG. 3, the optical disc drive 300 includes a first storage module 302, a second storage module 304, a microprocessor 312, a program counter 314, an address decoder (DEC) 316, and a program cache 318. In this embodiment, the first storage module 302 is implemented by non-volatile memory such as a flash ROM, and the second storage module 304 is implemented by volatile memory such as DRAM. The micro-code of the optical disc drive 300, i.e. micro-code 305, is stored in the first storage module 302. The micro-code 305 is primarily divided into a main core 306, a plurality of function codes 308, and a loader 310. The main core 306 contains the elements like a main routine, an update program, etc. In addition, each function code 308 corresponds to a specific function for a specific disc type, for example, a servo start-up function for CD-R disc, a servo start-up function for DVD-R disc, a seek function for CD-R disc, a seek function for DVD-R disc, and other disc drive related functions. Note that a loader 310 is also stored in the first storage module 302 and is executed to load the main core 306 into the second storage module 304 such that a duplicated main core 306′ is buffered in the second storage module 304. The data structure of the micro-code 305 is programmable. For instance, the designer can determine the total number of function codes 308 and the specific functions of the implemented function codes 308 according to design requirements. That is, the designer can consider factors relevant to the system performance of the optical disc drive 300, and the system performance can be optimized by determining which function codes are executed frequently. Additionally, the performance of the micro-code execution is affected by the core size. Therefore, it is important to consider which function codes must necessarily be integrated into the main core 306 and which function codes should become independent functions as function codes 308 shown in FIG. 3. The micro-code execution in the optical disc drive 300 is detailed as follows.

Please refer to FIG. 4 in conjunction with FIG. 3. FIG. 4 is a flowchart showing the micro-code execution of the optical disc drive 300. The micro-code execution includes the following steps:

Step 500: Power on the optical disc drive 300.

Step 510: Load the main core 306 from the first storage module 302 into the second storage module 304.

Step 520: Execute the loaded main core 306′ in the second storage module 304 to control operation of the optical disc drive 300.

Step 530: Check if an optical disc exists? If yes, then continue with the flow and go to step 540, if no, return to step 520.

Step 540: Check the type of inserted optical disc to see if the optical disc type is supported. If yes, then continue with the flow and go to step 550, if no, return to step 520.

Step 550: When a command is received from a host, execute the main core 306′ to switch execution of the main core 306′ to execution of a selected function code 308 in the first storage module 302 for running a specific function acting upon the optical disc.

Step 560: Switch execution of the selected function code 308 to execution of the main core 306′ when the specific function acting upon the optical disc is finished, and then go to step 520.

When the optical disc drive 300 boots up, the program counter 314 locates an appropriate memory address and the microprocessor 312 refers to the memory address pointed to by the program counter 314 for executing the loader 310 in the first storage module 302 (step 500). Please note that micro-code 305 of the optical disc drive 300 is executed by the microprocessor 312 to perform its designed functionality. That is, the microprocessor 312 dominates the operation of the optical disc drive 300 by executing the micro-code 305. In this embodiment, this loader 310 executed by the microprocessor 312 will transmit the main core 306 to a predetermined address of the second storage module 304 through PIO or DMA mode (step 510). When finished copying the main core 306, the loader 310 will then switch the program counter 314 to the starting address of the main core 306′ that was copied to the second storage module 304 (step 520). At the same time, the optical disc drive 300 is completely booted-up and begins to operate according to execution of the main core 306′. Then, the microprocessor 312 executes the main core 306′ to keep monitoring if an optical disc is inserted (step 530). If the optical disc exists, the microprocessor 312 executes the main core 306′ to check the type of the inserted optical disc (step 540). If the type of the inserted optical disc is supported by the optical disc drive 300, the optical disc drive 300 waits for commands issued by a host (e.g., the computer host). When the host generates a command for accessing the inserted optical disc, for example, a “read” command for a CD-R disc, the main core 306′ executed by the microprocessor 312 searches the first storage module 302 for a target function code 308 designed to handle data reading of CD-R discs, and then calls the target function code 308. In other words, the microprocessor 312 switches execution of the main core 306′ to execution of the selected function code 308 in the first storage module 302 for reading data on the CD-R disc in response to the received “read” command (step 550). When data requested by the “read” command have been obtained from the CD-R disc, the microprocessor 312 switches execution of the selected function code 308 to execution of the main core 306′ to terminate the “read” operation, and waits for following commands from the host (step 560). Thereafter, the main core 306′ will execute the same jump action, i.e., steps 550 and 560, when calling functions. That is, as the host generates a command for accessing the inserted optical disc, for example, a “write” command for CD-R disc, the main core 306′ executed by the microprocessor 312 calls another target function code 308 designed to handle data recording of CD-R disc. In short, when a specific function, which is not supported by the main core 306′, is needed, the switching between the first and second storage modules 302, 304 occurs for execution in the first storage module 302 to run the desired function code 308 designed to perform the needed function.

Based on this mechanism it is possible to combine the DEC 316 to instruct the microprocessor 312 to fetch program code in the second storage module 304 or the first storage module 302. In other words, the DEC 316 and the program counter 314 are components used to help the microprocessor 312 to execute program codes. Additionally, the program cache 318 is implemented to increase the program code executing speed of the main core 306′ buffered in the second storage module 304. The frequently executed command sets of the main core 306′ are cached in the program cache 318. In other words, the program cache 430 can increase the hit rate when caching the frequently executed command sets of the main core 306′. Therefore, when a target command set of the main core 306′ is to be executed again, the microprocessor 312, as known to those skilled in this art, directly executes the cached target command set instead of the target command set read from the second storage module 304.

As mentioned above, during the micro-code execution, the main core 306 is buffered in the second storage module 304 and executed from the second storage module 304 independent from the first storage module 302. In this embodiment, the main core 306, 306′ comprises the update function. Therefore, when the optical disc drive 300 detects a request for updating the micro-code 305, the microprocessor 312 running the current micro-code 305 will notify the program counter 314 and cause the program counter 314 to jump to the update program of the main core 306′. The update program is executed by the microprocessor 312, meanwhile, micro-code updating takes place in the first storage module 302, therefore the present invention will prevent a simultaneous read and write operation occurring in the flash ROM during the micro-code updating process. As a result, this greatly improves the micro-code updating efficiency.

In summary, the present invention provides a method for micro-code execution for an electronic device such as an optical disc drive. The present invention executes the main core in the second storage module (e.g. DRAM) to achieve better executing performance, makes use of the program cache to further increase the executing performance of the main core in the second storage module, eliminates inefficiency of executing the main core completely in the first storage module (e.g. flash ROM), and finally, the present invention prevents simultaneous read operations for accessing the main core and write operations for updating the micro-code.

Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims. 

1. A method for micro-code execution, comprising the steps of: loading a main core from a first storage module into a second storage module of a electronic device, and switching between the second storage module for executing the main core and the first storage module for executing one or a plurality of function codes to control operation of the electronic device; wherein the function code is executed when called by execution of the main core.
 2. The method of claim 1, wherein the first storage module is non-volatile memory.
 3. The method of claim 1, wherein the second storage module is volatile memory.
 4. The method of claim 1 further comprising the steps of: separately caching a target command set of the main core read from the second storage module when executing the target command set; and when the target command set is to be executed again, directly executing the cached target command set instead of the target command set from the second storage module.
 5. The method of claim 1, wherein the electronic device is a disc drive.
 6. The method of claim 5, wherein the micro-code is firmware of the disc drive.
 7. The method of claim 5, wherein each function code corresponds to a disc type, and the method further comprising the steps of: executing the main core to check a disc type of a disc; when the disc type is determined as a specific disc type and the corresponding function code is required to act upon the disc, switching execution of the main core to execution of the function code; and after the corresponding function code acting upon the disc is finished, switching execution of the function code to execution of the main core.
 8. The method of claim 1, wherein the main core comprises an update program, and the method further comprising the steps of: when data of the micro-code is required to be updated, executing the update program read from the second storage module to update the micro-code stored in the first storage module.
 9. An electronic device comprising: a first storage module storing a micro-code partitioned into a main core and at least a function code; a second storage module; and a microprocessor, coupled to the first storage module and the second storage module, for loading the main core from the first storage module into the second storage module and for switching between the second storage module for executing the main core and the first storage module for executing the function code to control operation of the electronic device; wherein the function code is executed when called by execution of the main core.
 10. The electronic device of claim 9, wherein the first storage module is non-volatile memory.
 11. The electronic device of claim 9, wherein the second storage module is volatile memory.
 12. The electronic device of claim 9 further comprising: a program cache, coupled with the second storage module and the microprocessor, for caching a target command set of the main core read from the second storage module when executing the target command set; wherein when the target command set is to be executed again, the microprocessor directly executes the cached target command set instead of the target command set from the second storage module.
 13. The electronic device of claim 9 being a disc drive.
 14. The electronic device of claim 13, wherein the micro-code is firmware of the disc drive.
 15. The electronic device of claim 13, wherein the micro-code includes a plurality of function codes each corresponding to a disc type, and the microprocessor executes the main core to check a disc type of a disc, switches execution of the main core to execution of the function code when the disc type is determined as a specific disc type and the corresponding function code is required to act upon the disc, and switches execution of the function code to execution of the main core when the corresponding function code acting upon the disc is finished.
 16. The electronic device of claim 9, wherein the main core comprises an update program, and when data of the micro-code is required to be updated, the microprocessor executes the update program of the main core read from the second storage module to update the micro-code stored in the first storage module. 